﻿using System;
using System.Threading;


namespace AI_Experiment
{
    class Food
    {
        public int Id;
        public int AliveTime;
        public int cur_x;
        public int cur_y;
        public bool isEaten; //this becomes true when the food is eaten, probably will be a method
                                            //that is waiting for this to become true, then notifies logging
                                            //functionality(wherever that may be) and logs time, who ate etc
        private Thread t;

        public Food(int id)
        {
            Id = id;
            isEaten = false;
            cur_x = GlobalVars.random.Next(0, GlobalVars.boardSize_x);
            cur_y = GlobalVars.random.Next(0, GlobalVars.boardSize_y);
            AliveTime = 0;
            ThreadStart start = new ThreadStart(StartTimer);
            t = new Thread(start);
        }

        private void StartTimer()
        {
            while (isEaten == false)
            {
                System.Threading.Thread.Sleep(1000);
                AliveTime++;
            }
        }

    }
}